package com.example.liyun.joy;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;


class ViewPagerAdapter extends FragmentPagerAdapter {
    private List<Fragment> list;
    public void setList(List<Fragment> list){
        this.list=list;
        notifyDataSetChanged();
    }

    public ViewPagerAdapter(FragmentManager fm) {
        super(fm);

    }

    @Override
    public Fragment getItem(int i) {
        return list.get(i);
    }

    /**
     * 获得fragment的个数
     * @return
     */
    @Override
    public int getCount() {
        //如果list不等于空，返回list个数，否则返回0
        return list!=null?list.size():0;
    }
}
